﻿
package extremefx.modules.css {
	import extremefx.ICloneable;
	
	import flash.text.TextField;
	import flash.text.TextFormat;	

	/**
	 * @author Marcelo Volmaro
	 */
	public class XTextFormat extends TextFormat implements ICloneable {
		public var name:String;
		
		public function XTextFormat() {
			super("Tahoma", 12, 0, false, false, false, null, null, "left", 0, 0, 0, 0);
			antiAliasType = "normal";
			gridFitType = "none";
			_filters = [];
		}
		
		private var _filters:Array; 
		 
		public function get filters():Array { 
			return _filters; 
		} 
		
		public function set filters(pValue:Array): void { 
			_filters = pValue || [];
		}
		
		public var embedFonts:Boolean;
		public var antiAliasType:String;
		public var gridFitType:String;
		public var vAlign:String;
//		public var offset:Point;
		
		public function applyToTextfield(pTf:TextField):void {
			if ((pTf.embedFonts = embedFonts)) {
				pTf.antiAliasType = antiAliasType;
				pTf.gridFitType = gridFitType;
			}
			
			pTf.defaultTextFormat = this;
			pTf.setTextFormat(this);
			pTf.filters = _filters;
		}
		
		public function clone():Object {
			var tf:XTextFormat = new XTextFormat();
			with (tf){
				font = this.font;
				size = this.size;
				color = this.color;
				bold = this.bold;
				italic = this.italic;
				underline = this.underline;
//				url = this.url;
//				target = this.target;
				align = this.align;
				indent = this.indent;
				leading = this.leading;
				embedFonts = this.embedFonts;
				antiAliasType = this.antiAliasType;
				gridFitType = this.gridFitType;
				_filters = this._filters.splice();
			};
			
			return tf;
		}
	}
}
